/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.ukni.persistence.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author eurico
 */
@Entity
@Table(name = "BAND")
@NamedQueries({@NamedQuery(name = "Band.findAll", query = "SELECT b FROM Band b"), @NamedQuery(name = "Band.findByIdband", query = "SELECT b FROM Band b WHERE b.idband = :idband"), @NamedQuery(name = "Band.findByName", query = "SELECT b FROM Band b WHERE b.name = :name"), @NamedQuery(name = "Band.findByFormed", query = "SELECT b FROM Band b WHERE b.formed = :formed"), @NamedQuery(name = "Band.findByDescription", query = "SELECT b FROM Band b WHERE b.description = :description"), @NamedQuery(name = "Band.findByDatecreation", query = "SELECT b FROM Band b WHERE b.datecreation = :datecreation")})
public class Band implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "IDBAND")
    private Integer idband;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @Column(name = "FORMED")
    @Temporal(TemporalType.DATE)
    private Date formed;
    @Basic(optional = false)
    @Column(name = "DESCRIPTION")
    private String description;
    @Basic(optional = false)
    @Lob
    @Column(name = "BIOGRAPHY")
    private String biography;
    @Basic(optional = false)
    @Column(name = "DATECREATION")
    @Temporal(TemporalType.DATE)
    private Date datecreation;
    @ManyToMany(mappedBy = "bandCollection", fetch = FetchType.EAGER)
    private Set<Account> accountCollection;
    @JoinTable(name = "BANDGENRE", joinColumns = {@JoinColumn(name = "REFIDBAND", referencedColumnName = "IDBAND")}, inverseJoinColumns = {@JoinColumn(name = "REFIDGENRE", referencedColumnName = "IDGENRE")})
    @ManyToMany(fetch = FetchType.EAGER)
    private Set<Genre> genreCollection;
    @JoinTable(name = "CALENDAR", joinColumns = {@JoinColumn(name = "REFIDBAND", referencedColumnName = "IDBAND")}, inverseJoinColumns = {@JoinColumn(name = "REFIDEVENT", referencedColumnName = "IDEVENT")})
    @ManyToMany(fetch = FetchType.EAGER)
    private Set<Event> eventCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refidband", fetch = FetchType.EAGER)
    private Set<Image> imageCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refidband", fetch = FetchType.EAGER)
    private Set<Video> videoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refidband", fetch = FetchType.EAGER)
    private Set<Bandelement> bandelementCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "band", fetch = FetchType.EAGER)
    private Set<CommentBand> commentBandCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refidband", fetch = FetchType.EAGER)
    private Set<Audio> audioCollection;
    @JoinColumn(name = "IDBAND", referencedColumnName = "IDACCOUNT", insertable = false, updatable = false)
    @OneToOne(optional = false, fetch = FetchType.EAGER)
    private Account account;

    public Band() {
    }

    public Band(Integer idband) {
        this.idband = idband;
    }

    public Band(Integer idband, String name, Date formed, String description, String biography, Date datecreation) {
        this.idband = idband;
        this.name = name;
        this.formed = formed;
        this.description = description;
        this.biography = biography;
        this.datecreation = datecreation;
    }

    public Integer getIdband() {
        return idband;
    }

    public void setIdband(Integer idband) {
        this.idband = idband;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getFormed() {
        return formed;
    }

    public void setFormed(Date formed) {
        this.formed = formed;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getBiography() {
        return biography;
    }

    public void setBiography(String biography) {
        this.biography = biography;
    }

    public Date getDatecreation() {
        return datecreation;
    }

    public void setDatecreation(Date datecreation) {
        this.datecreation = datecreation;
    }

    public Set<Account> getAccountCollection() {
        return accountCollection;
    }

    public void setAccountCollection(Set<Account> accountCollection) {
        this.accountCollection = accountCollection;
    }

    public Set<Genre> getGenreCollection() {
        return genreCollection;
    }

    public void setGenreCollection(Set<Genre> genreCollection) {
        this.genreCollection = genreCollection;
    }

    public Set<Event> getEventCollection() {
        return eventCollection;
    }

    public void setEventCollection(Set<Event> eventCollection) {
        this.eventCollection = eventCollection;
    }

    public Set<Image> getImageCollection() {
        return imageCollection;
    }

    public void setImageCollection(Set<Image> imageCollection) {
        this.imageCollection = imageCollection;
    }

    public Set<Video> getVideoCollection() {
        return videoCollection;
    }

    public void setVideoCollection(Set<Video> videoCollection) {
        this.videoCollection = videoCollection;
    }

    public Set<Bandelement> getBandelementCollection() {
        return bandelementCollection;
    }

    public void setBandelementCollection(Set<Bandelement> bandelementCollection) {
        this.bandelementCollection = bandelementCollection;
    }

    public Set<CommentBand> getCommentBandCollection() {
        return commentBandCollection;
    }

    public void setCommentBandCollection(Set<CommentBand> commentBandCollection) {
        this.commentBandCollection = commentBandCollection;
    }

    public Set<Audio> getAudioCollection() {
        return audioCollection;
    }

    public void setAudioCollection(Set<Audio> audioCollection) {
        this.audioCollection = audioCollection;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idband != null ? idband.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Band)) {
            return false;
        }
        Band other = (Band) object;
        if ((this.idband == null && other.idband != null) || (this.idband != null && !this.idband.equals(other.idband))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "deti.es.ukni.persistence.entity.Band[idband=" + idband + "]";
    }

}
